package com.qfedu.zf.life.controller;


import cn.hutool.core.convert.NumberWithFormat;
import com.qfedu.zf.common.config.SystemConfig;

import com.qfedu.zf.common.param.CheckinDTO;
import com.qfedu.zf.common.utils.JwtUtil;

import com.qfedu.zf.life.service.CheckinRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author wjw
 * @since 2024-06-21
 */
@RestController
@RequestMapping("/sign")
public class CheckinRecordController {

    @Autowired
    private CheckinRecordService checkinRecordService;

    @PostMapping("/check")
    public void checkin(HttpServletRequest request) {

        // 配置userid
        String token = request.getHeader(SystemConfig.HEADER_TOKEN);
        Long id = (long) ((NumberWithFormat) JwtUtil.parseToken(token, "id")).intValue();

        CheckinDTO checkinDTO = new CheckinDTO();

        checkinDTO.setUserId(id);

         checkinRecordService.checkin(checkinDTO);
    }

}

